<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>平台管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="/layuiadmin/layui/css/layui.css"
	media="all">
<link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="/css/plat-style.css" media="all">
<style>
thead tr th {
	text-align: center !important;
	font-weight: bold !important;
}

tr td {
	text-align: center !important;
}

.layui-card-header .goodsMoney {
    line-height: initial;
    position: absolute;
    right: 15px;
    top: 50%;
    margin-top: -7px;
}
</style>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-body layui-form">
						<%-- 查询条件设置 --%>
						<div class="layui-container layui-form-item"
							style="padding-bottom: 50px">
							<!---->
							<!-- 商品信息 -->
							<div class="layui-card-header">商品信息</div>
							<div class="layui-table-body layui-table-main">
								<table class="layui-table" lay-size="lg" border="1">
									<thead>
										<tr>
											<th><div class="cell">商品图片</div></th>
											<th><div class="layui-table-cell">商品名称</div></th>
											<th><div class="layui-table-cell">规格信息</div></th>
											<th><div class="layui-table-cell">单价</div></th>
											<th><div class="layui-table-cell">数量</div></th>
											<th><div class="layui-table-cell">小计</div></th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td><div class="cell">
													<img src="${orderDetail.proUrl }" width="80px;" height="80px;" />
												</div></td>
											<td><div class="layui-table-cell">${orderDetail.proName }</div></td>
											<td><div class="layui-table-cell">${orderDetail.proSpecName }</div></td>
											<td><div class="layui-table-cell">${orderDetail.price }</div></td>
											<td><div class="layui-table-cell">${orderDetail.qty }</div></td>
											<td><div class="layui-table-cell">${orderDetail.qty*orderDetail.price }</div></td>
										</tr>
									</tbody>
								</table>
							</div>
							
							<!-- 退款信息 -->
							<div class="layui-card-header">退款信息</div>
							<div class="layui-form-item">
					        	<label class="layui-form-label">订单编号：</label>
					        	<div class="layui-form-mid layui-word-aux">${refund.orderCode }</div>
					        </div>
							<div class="layui-form-item">
					        	<label class="layui-form-label">退款编号：</label>
					        	<div class="layui-form-mid layui-word-aux">${refund.refundCode }</div>
					        </div>
							<div class="layui-form-item">
					        	<label class="layui-form-label">状态：</label>
					        	<div class="layui-form-mid layui-word-aux">
					        		<c:forEach var="l" items="${refundStatus }">
					        			<c:if test="${refund.status == l.id }">${l.name }</c:if>
					        		</c:forEach>
					        	</div>
					        </div>
					        <div class="layui-form-item">
					        	<label class="layui-form-label">退款类型：</label>
					        	<div class="layui-form-mid layui-word-aux">
					        		<c:if test="${refund.applyType == 1 }">仅退款</c:if>
					        		<c:if test="${refund.applyType == 2 }">退款退货</c:if>
					        	</div>
					        </div>
							<div class="layui-form-item">
					        	<label class="layui-form-label">申请时间：</label>
					        	<div class="layui-form-mid layui-word-aux">
					        		<fmt:formatDate value="${refund.createTime }" pattern="yyyy-MM-dd HH:mm"/>
					        	</div>
					        </div>
							<div class="layui-form-item">
					        	<label class="layui-form-label">退款原因：</label>
					        	<div class="layui-form-mid layui-word-aux">${refund.refundReason }</div>
					        </div>
					        <div class="layui-form-item">
					        	<label class="layui-form-label">退款金额：</label>
					        	<div class="layui-form-mid layui-word-aux">${refund.refundMoney }</div>
					        </div>
					        <div class="layui-form-item">
					        	<label class="layui-form-label">退款凭证：</label>
					        	<div class="layui-form-mid layui-word-aux">
					        		<c:forTokens items="${refund.refundImgs }" delims="," var="img">
						        		<img src="${img }"/>
					        		</c:forTokens>
					        	</div>
					        </div>
					        <c:if test="${authen.status != 1 }">
						        <div class="layui-form-item">
						        	<label class="layui-form-label">审核时间：</label>
						        	<div class="layui-form-mid layui-word-aux">
						        		<fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${refund.checkTime }" />
						        	</div>
						        </div>
						        <div class="layui-form-item">
						        	<label class="layui-form-label">备注：</label>
						        	<div class="layui-form-mid layui-word-aux">${refund.rejectRemark }</div>
						        </div>
					        </c:if>
					        <div class="layui-form-item">
				                <div class="layui-input-block">
				                	<c:choose>
				                		<c:when test="${refund.status == 1 }">
											<button data-id="${refund.id}" data-type="passThis" type="button"
													class="layui-btn layui-btn-sm layui-btn-normal passThis">通过</button>
				                			<button data-id="${refund.id}" data-type="rejectThis" type="button"
													class="layui-btn layui-btn-sm layui-btn-warm rejectThis">驳回</button>
				                		</c:when>
				                		<c:otherwise>
				                			<button class="layui-btn backList">返回列表</button>
				                		</c:otherwise>
				                	</c:choose>
				                </div>
				            </div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script src="/layuiadmin/layui/layui.js"></script>
	<script src="/js/common.js"></script>
	<script>
		layui.config({
			//静态资源所在路径
			base : '/layuiadmin/'
		}).extend({
			//主入口模块
			index : 'lib/index'
		}).use([ 'index', 'form'],function() {
			var $ = layui.$, admin = layui.admin, element = layui.element, layer = layui.layer;
			
			var active = {
				//驳回退款申请
				rejectThis : function(id){
					layer.prompt({title: '驳回退款申请', formType: 2}, function(text, index){
						$.ajax({
							type: 'post',
							url: '/order/handleRefundReject',
							data: {'refundId': id,'rejectRemark':text},
							dataType: 'json',
							success: function (data) {
								if (data.status) {
									layer.msg(data.desc);
									setTimeout(function () {
										window.location.reload();
									}, 1000)
								} else {
									layer.msg(data.desc);
								}
							},
							error: function (a,b,c) {
								layer.msg("请检查页面信息是否正确");
							}
						});
					});
				},
				//通过退款申请
				passThis : function (id) {
					layer.confirm('确定操作吗？', function(){
						$.ajax({
							url: "/order/handleRefundSuccess",
							data: {'refundId': id},
							dataType: "json",
							type: "post",
							success: function (data) {
								if (data.status) {
									layer.msg(data.desc);
									setTimeout(function () {
										window.location.reload();
									}, 1000)
								} else {
									layer.msg(data.desc);
								}
							}
						})
					});
				}
		   	};
			
			$('.backList').on('click',function () {
				history.go(-1);
			});
			
			//同意退款申请触发事件
			$('.passThis').on('click', function(){
				var passThis = $(this).data('type');
				var id = $(this).data('id');
				active[passThis] && active[passThis].call(this,id);
			});
			//驳回退款触发事件
			$('.rejectThis').on('click', function(){
				var rejectThis = $(this).data('type');
				var id = $(this).data('id');
				active[rejectThis] && active[rejectThis].call(this,id);
			});
			
		});
	</script>
</body>
</html>